#include <stdio.h>
#include <string.h>
#include "seqlist.h"

typedef struct _Teacher
{
        int age;
        char name[64];
}Teacher;


//线性表的顺序存储结构与实现
int main(int argc, char const *argv[])
{
        int ret = 0;
        SeqList* list = NULL;
        Teacher t1, t2, t3, t4, t5;
        t1.age = 31;  strcpy(t1.name, "t1");
        t2.age = 32;  strcpy(t2.name, "t2");
        t3.age = 33;  strcpy(t3.name, "t3");
        t4.age = 34;  strcpy(t4.name, "t4");
        t5.age = 35;  strcpy(t5.name, "t5");
        
        list =  SeqList_Create(10);
        if(list == NULL){
                printf("func SeqList_Create failed \n");
                return -1;
        }

        ret = SeqList_Insert(list, (SeqListNode *)&t1, 0); //头插法
        ret = SeqList_Insert(list, (SeqListNode *)&t2, 0); //头插法
        ret = SeqList_Insert(list, (SeqListNode *)&t3, 0); //头插法
        ret = SeqList_Insert(list, (SeqListNode *)&t4, 0); //头插法
        ret = SeqList_Insert(list, (SeqListNode *)&t5, 0); //头插法

        for (int i = 0; i < SeqList_Length(list); i++)
        {
               Teacher* tmp = (Teacher *)SeqList_Get(list, i);
               if(tmp == NULL){
                       printf("func SeqList_Get failed \n");
                       return -1;
               }
               printf("name: %s, age: %d \n", tmp->name, tmp->age);
        }
        
        while (SeqList_Length(list) > 0)
        {
                SeqList_Delete(list, 0);
        }

        printf("hello world \n");
        return 0;
}
